package Sort;

import java.util.Arrays;
import java.util.Random;

import static Sort.Sort.insertSort;
import static Sort.Sort.selectSort;

public class Text {
    public static void InitInsertSort(int[] array) {//测试逆序情况下
        for (int i = 0; i < array.length; i++) {
            array[i] = array.length - i;
        }
    }
    public static void InsertSort(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
        }
    }
    public static void InsertNotSort(int[] array) {//测试无序情况下
        Random random = new Random();//生成随机数
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(10_0000);
        }
    }
    public static void textInsertSort(int[] array) {//测试方法
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        insertSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序耗时：" +(endTime-startTime));
    }
    public static void textSelectSort(int[] array) {//测试方法
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        selectSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("选择排序耗时：" +(endTime-startTime));
    }
    public static void main2(String[] args) {
        int[] array = new int[10_0000];
        //InsertSort(array);//有序情况
        //InsertNotSort(array);//无序情况
        //InitInsertSort(array);//逆序情况
        //InitInsertSort(array);
        textSelectSort(array);

    }
    public static void main(String[] args) {
        int[] array1 = {1,21,43,32,55,67,22};
        int[] array = {5,2,3,1};
        int[] array2 = {1,1,2,3,5,7,9,4,2,4,5,6,8,8};
        //Sort.insertSort(array);
        //Sort.shellSort(array);
        //Sort.quickSort(array);
        //Sort.mergrSort1(array);
        //SortPractice.mergrSort2(array);
        //Sort.mergrSort3(array);
        //SortPractice.bubbleSort(array);
        //SortPractice.insertSort(array);
        Sort.countSort(array2);
        System.out.println(Arrays.toString(array2));
    }
}
